home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-06-25 | 1.7 KB | 72 lines | [TEXT/?bDv] |
- !
- ! Suicide
- !
- ! This bot looks for other bots much like Bomber, except that
- ! when it sees another bot, it turns on its shield and charges
- ! at it full tilt.
- !
-
- #DATA
-
- equ INCR 23
-
- def scn
- def xx
- def yy
- def damage
-
- #CODE BASIC
-
- scn = Random(360)
- damage = $DAMAGE
- xx = Random(200)+25
- yy = Random(200)+25
-
- ! The following few lines in fact make up the entire body
- ! of this bot's code. Everything else is done in
- ! subroutines.
-
- :Loop
- If (damage <> $DAMAGE) Then Gosub Moveaway
- scn = scn + INCR
- Scan Angle scn
- If ($FOUND == 0) Then Goto Loop
-
- Gosub Attack
- Gosub Moveaway
- Goto Loop
-
-
- ! In order to move at a given angle (here, the angle to the
- ! enemy bot), set velocity to (cos(angle), sin(angle)).
-
- :Attack
- Velocity Cos($ANGLE), Sin($ANGLE)
- Shield ON ! To reduce the expected damage
- :ALoop
- If ($XVEL <> 0) Then Goto ALoop ! After a collision, a bot
- If ($YVEL <> 0) Then Goto ALoop ! automatically tries to
- ! decelerate to (0,0)
- ! velocity
- Shield OFF
- Return
-
- ! The following subroutine is a bit different than the previous
- ! movement routines. Instead of moving *to* a point in the
- ! arena, the bot moves *toward* a point for 20 ticks. This
- ! risks smashing into walls (as the bot doesn't slow down), but
- ! it's easier to write than the other routine, and the bot
- ! won't completely choke if its treads are destroyed (as Bomber
- ! will -- it goes into an infinite loop trying to move to the
- ! specified point when the bot can no longer move at all).
-
- :Moveaway
- Velocity (xx-$XLOC)*10, (yy-$YLOC)*10
- Wait 20 ! Move for 20 ticks
- Velocity 0, 0
- damage = $DAMAGE
- xx = Random(200)+25 ! Compute the new target point
- yy = Random(200)+25
- Return
-
- #END